package pap.test.fcPuGm;

import gov.nasa.jpf.jvm.Verify;
import java.util.List;

public class GUIManager extends Thread {

	private BufferManager buffer;
	private List<Body> bodies;
	int numBodies, iterations;

	public GUIManager(BufferManager buffer, int numBodies, int iterations) {
		Verify.beginAtomic();
		this.buffer = buffer;
		this.numBodies = numBodies;
		this.iterations = iterations;
		Verify.endAtomic();
	}

	public void run() {
		for (int i = 0; i < iterations / numBodies; i++) {
			try {
				drawStep();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * Retrieves the next step to draw from the buffer manager and sends it to
	 * the GUI
	 * 
	 * @throws InterruptedException
	 */
	public void drawStep() throws InterruptedException {
		bodies = buffer.getNextList();
	}

}
